﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using YArchitech.Controls;
using YArchitech.HVAC.PipeSetting;
using YArchitech.LIB;

namespace YArchitech.Plumbing
{
	public partial class FormExpandSystemType : HYBaseForm
	{
		public FormExpandSystemType(System.Drawing.Point _pXYZ, object systemTypeInfoList, string strCurrentSystemType, int functions = 0)
		{
			this.InitializeComponent();
			this.mPXYZ = _pXYZ;
			this.mSystemTypeInfoList = (IList<SystemTypeInfo>)systemTypeInfoList;
			this.mstrCurrentSystemType = strCurrentSystemType;
			this.function = functions;
			if (this.function == 0)
			{
				HYSystemType.strSelectedSystemType = strCurrentSystemType;
			}
			else if (this.function == 1)
			{
				HYHeatingPipeSystemType.strSelectedSystemType = strCurrentSystemType;
			}
			FormExpandSystemType.flag = false;
		}

		private void btnExit_Click(object sender, EventArgs e)
		{
			base.Dispose();
		}

		private void FormExpandSystemType_Load(object sender, EventArgs e)
		{
			base.Location = this.mPXYZ;
			new StringBuilder();
			int num = 0;
			int num2 = 0;
			foreach (SystemTypeInfo systemTypeInfo in this.mSystemTypeInfoList)
			{
				int num3 = StringTools.GetStringByteLength(systemTypeInfo.SysType) * 7;
				num2 = ((num2 < num3) ? num3 : num2);
				bool isChecked = (string.IsNullOrEmpty(this.mstrCurrentSystemType) && num == 0) || systemTypeInfo.SysType == this.mstrCurrentSystemType;
				this.lstBoxSystemType.Items.Add(systemTypeInfo.SysType, isChecked);
				num++;
			}
			base.Height = (this.mSystemTypeInfoList.Count + 1) * 16;
			this.lstBoxSystemType.Height = (this.mSystemTypeInfoList.Count + 1) * 16;
			base.Width = num2 + 18;
			this.lstBoxSystemType.Width = num2 + 18;
		}

		private void lstBoxSystemType_SelectedIndexChanged(object sender, EventArgs e)
		{
			int selectedIndex = this.lstBoxSystemType.SelectedIndex;
			if (selectedIndex == -1)
			{
				return;
			}
			for (int i = 0; i < this.lstBoxSystemType.Items.Count; i++)
			{
				bool value = i == selectedIndex;
				this.lstBoxSystemType.SetItemChecked(i, value);
			}
			if (this.function == 0)
			{
				HYSystemType.strSelectedSystemType = this.lstBoxSystemType.Items[selectedIndex].ToString();
			}
			else if (this.function == 1)
			{
				HYHeatingPipeSystemType.strSelectedSystemType = this.lstBoxSystemType.Items[selectedIndex].ToString();
			}
			FormExpandSystemType.flag = true;
			base.Close();
		}

		private void lstBoxSystemType_MouseLeave(object sender, EventArgs e)
		{
			base.Close();
		}

		private void lstBoxSystemType_MouseClick(object sender, MouseEventArgs e)
		{
			base.Close();
		}

		private System.Drawing.Point mPXYZ;

		private IList<SystemTypeInfo> mSystemTypeInfoList;

		private string mstrCurrentSystemType;

		public static bool flag;

		private int function;
	}
}
